package otcv.hr.webapp.dao;

import java.io.IOException;
import java.io.Reader;

import otcv.hr.log.Logger;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class Dao {

	protected static SqlMapClient sqlMap;

	public Dao() {
		if (sqlMap == null) {
			String resource = "otcv/hr/appconf/sqlMapConfig.xml";
			try {
				Reader configReader = Resources.getResourceAsReader(resource);
				sqlMap = SqlMapClientBuilder.buildSqlMapClient(configReader);
				configReader.close();
			} catch (IOException iex) {
				Logger.error("Can't load '" + resource + "'");
			}
		}
	}
}